<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script src="../js/jquery-3.4.1.min.js"></script>
    <script src="../js/form2json.js"></script>
    <script>

        function sub() {

            $.ajax({
                //请求路径
                url:"/user",
                //请求参数
                data:$("#f01").formToJson(),
                //请求方式
                type:"POST",
                //数据响应格式
                dataType:"JSON",
                //成功 操作

                success:function (res) {
                    alert("添加成功")

                    location.href="list.html";
                },

                error:function (res) {

                    alert("添加功能失败,服务器异常")

                }
            })
        }
    </script>

</head>
<body>

<h1>添加功能</h1>


<form action="" id = "f01">
    <table  width="500px">

        <tr>
            <td>登录名</td>
            <td>
                <input type="text" name="loginName">
            </td>
        </tr>

        <tr>
            <td>密码</td>
            <td>
                <input type="text" name="loginPwd">
            </td>
        </tr>


        <tr>
            <td></td>
            <td>
                <input type="button"  onclick="sub()" value="确定">
            </td>
        </tr>


    </table>

</form>





</body>
</html>